//
//  GpsHistoryViewController.m
//  OST
//
//  Created by mac on 13-7-18.
//  Copyright (c) 2013年 mac. All rights reserved.
//

#import "GpsHistoryViewController.h"
#import "GpsHistoryCell.h"
#import "GpsHistoryData.h"

#import "MapViewController.h"

@interface GpsHistoryViewController ()

@end

@implementation GpsHistoryViewController
@synthesize data;

- (void)viewDidLoad
{
    [super viewDidLoad];
    closeNextPage = YES;
    threadLoadData = NO;
    
    [self addBottomView];
    dataTableView.frame = CGRectMake(0, 0, 320, self.view.frame.size.height - 60);
    self.title =@"Gps";
    
    [self refreshData];
}


-(CGFloat)rowHeight
{
    return 76;
}

- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
	NSUInteger row=[indexPath row];
    static NSString *GpsHistoryCellIdentifier = @"GpsHistoryCellIdentifier";
    GpsHistoryCell *cell = (GpsHistoryCell*)[dataTableView dequeueReusableCellWithIdentifier:GpsHistoryCellIdentifier];
    if (cell==nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"GpsHistoryCell" owner:self options:nil]lastObject];
        [cell initView];
    }
    NSDictionary *rowData = [self.rows objectAtIndex:row];
    cell.data = rowData;
    return cell;
}

-(void)didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
	NSUInteger row=[indexPath row];
    NSDictionary *rowData = [self.rows objectAtIndex:row];
    MapViewController *map = [[MapViewController alloc]init];
    map.type = 2;
    map.mid = [rowData objectForKey:@"value"];
    [self.navigationController pushViewController:map animated:YES];
}


-(NSArray *)loadPageData:(int)page
{
    [activity startAnimating];
    GpsHistoryData *gpsHistoryData = [[GpsHistoryData alloc]init];
    gpsHistoryData.ids = [data objectForKey:@"id"];
    [gpsHistoryData getDataWithDataRecivedBlock:^(id xdata) {
        [activity stopAnimating];
        [super doneLoadingTableViewData:xdata];
    }];
    
    return nil;
}

@end
